﻿using Coolzon.UI.Core.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace Coolzon.UI.Core.Runtime.Script.Animation
{
    public class FuncAnimationScriptObject : AnimationScriptObject
    {
        Action _func;

        public FuncAnimationScriptObject(object func)
            : base(0)
        {
            _func = (Action)func;
        }

        public override void AppendToStoryboard(Widget instance, ref double duration, Storyboard storyboard)
        {
            storyboard.Completed += storyboard_Completed;
        }

        void storyboard_Completed(object sender, EventArgs e)
        {
            if(_func!=null)
            {
                _func.Invoke();
            }
        }
    }
}
